from selenium.webdriver.support.wait import WebDriverWait

from utils import DriverTools


class BasePage(object):

    def find_el(self, loc):
        self.driver = DriverTools.get_driver()
        el = WebDriverWait(self.driver, 10, 1).until(lambda x: x.find_element(loc[0], loc[1]))
        return el

    def input(self, loc, content):
        """
      模拟输入

      :param loc: 元素的定位信息

      :param content: 要输入的 内容

      :return: None
      """
        el = self.find_el(loc)
        el.clear()
        el.send_keys(content)


    def click(self, loc):
        el = self.find_el(loc)
        el.click()



    def get_alert_text(self,loc):
        """获取弹出框文本"""
        return self.find_el(loc).text


